
/* TEAM B
 * Hotel Management System 
 * 
 * Team members
	

 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.*;

public class WolfVillas {
	private static final String jdbcURL = "jdbc:oracle:thin:@ora.csc.ncsu.edu:1523:orcl";

	// Put your oracle ID and password here
	private static final String user = "svpendse";
	private static final String password = "dbmsenter";


	private static Connection connection;

	public static void main(String[] args) throws Exception {


		try {
/*			Class.forName("oracle.jdbc.driver.OracleDriver");


			connection = null;
			connection = DriverManager.getConnection(jdbcURL, user, password);
*/
			start();

			while(true){

				//give options for menu.
				System.out.println("Choose a category \n");
				System.out.println("1.Information Processing \n");
				System.out.println("2.Maintaining Service Availed Records \n");
				System.out.println("3.Maintaining Bill accounts\n");
				System.out.println("4.Reports \n");
				System.out.println("Type -1 to exit \n");

				//take input and call corresponding function.

				BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
				int ch = Integer.parseInt(br.readLine());

				if(ch == -1)
				{
					System.out.println("Exiting application..");
					break;			

				}
				switch(ch)
				{
				case 1: 
					InfoProcessor ip = new InfoProcessor(connection);
	//				infProcessing();
				break;  
				case 2:
					ServiceMaintainer sm = new ServiceMaintainer(connection);
	//				 maintainservicerecords();
				break;
				case 3: 
					BillMaintainer bm = new BillMaintainer(connection);
//					maintainbillaccounts();
				break;
				case 4: 
					ReportGenerator rg = new ReportGenerator(connection);
					//rg.reportPercentRoomsOccupied();
					rg.reportStaffByRole("Front Desk");
					rg.reportOccByHotel();
					rg.reportOccByRoomType();
					rg.reportOccByDateRange("2012-01-11 10:00:00","2012-01-13 10:00:00");
					rg.reportOccupants("2012-01-11 10:00:00","2012-01-13 10:00:00");
					rg.reportCustomerByStaff(211, "2012-01-11 10:00:00", "2012-04-13 10:00:00");
//					reports();
				break;
				default:
					System.out.println("Enter a valid option");
				}

				// break;

			}     
			//close connection. 
			close(connection);

		} catch(Exception e) {	
			e.printStackTrace();
		}

	}

	static void start() throws Exception
	{
			Class.forName("oracle.jdbc.driver.OracleDriver");
			connection = null;
			connection = DriverManager.getConnection(jdbcURL, user, password);
	}
	static void close(Connection connection) {
		if(connection != null) {
			try { 
				connection.close(); 
			} catch(Throwable whatever) {}
		}
	}
	
	// Close statement and Result code
	static void close(Statement statement) {
		if(statement != null) {
			try { 
				statement.close(); 
			} catch(Throwable whatever) {}
		}
	}
	static void close(ResultSet result) {
		if(result != null) {
			try { 
				result.close(); 
			} catch(Throwable whatever) {}
		}
	}
}

